package com.cimu.ehcache.service.impl;

import com.cimu.ehcache.entity.User;
import com.cimu.ehcache.mapper.UserDao;
import com.cimu.ehcache.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Title: UserServiceImpl
 * Copyright: Copyright (c) 2017
 *
 * date 2018年12月19日 14:17
 */
@Service
@CacheConfig(cacheNames="demo")
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Cacheable(value="demo")
    @Override
    @Caching(cacheable={@Cacheable(value = "test"),@Cacheable(value="test2")})
    public List<User> getByAll() {
        return userDao.getByAll();
    }

    @CacheEvict(value="demo",allEntries = true)
    @Override
    public void update() {

    }

}
